package net.guruqu.rvoView;

import java.awt.BorderLayout;
import javax.swing.JPanel;
import javax.swing.JFrame;
import javax.swing.JButton;
import javax.swing.JToggleButton;
import java.awt.GridLayout;
import java.awt.Dimension;

public class SwitchingPanel extends JFrame {

	private static final long serialVersionUID = 1L;
	private JPanel jContentPane = null;
	private JToggleButton simulationToggle = null;
	private JToggleButton toggleMapDef = null;
	public JFrame[] mapDefineFrames;
	public JFrame simulationFrame;

	/**
	 * This is the default constructor
	 */
	public SwitchingPanel() {
		super();
		initialize();
	}

	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
		this.setSize(303, 86);
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.setResizable(false);
		this.setContentPane(getJContentPane());
		this.setTitle("Simulation Window Switcher");
	}

	/**
	 * This method initializes jContentPane
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getJContentPane() {
		if (jContentPane == null) {
			GridLayout gridLayout = new GridLayout();
			gridLayout.setRows(1);
			jContentPane = new JPanel();
			jContentPane.setLayout(gridLayout);
			jContentPane.add(getSimulationToggle(), null);
			jContentPane.add(getToggleMapDef(), null);
		}
		return jContentPane;
	}

	/**
	 * This method initializes simulationToggle
	 * 
	 * @return javax.swing.JToggleButton
	 */
	private JToggleButton getSimulationToggle() {
		if (simulationToggle == null) {
			simulationToggle = new JToggleButton();
			simulationToggle.setText("Simulation ");
			simulationToggle.setSelected(false);
			simulationToggle
					.addActionListener(new java.awt.event.ActionListener() {
						public void actionPerformed(java.awt.event.ActionEvent e) {
							if (simulationToggle.isSelected()) {
								simulationFrame.setVisible(true);
							} else {
								simulationFrame.setVisible(false);
							}
						}
					});
		}
		return simulationToggle;
	}

	/**
	 * This method initializes toggleMapDef
	 * 
	 * @return javax.swing.JToggleButton
	 */
	private JToggleButton getToggleMapDef() {
		if (toggleMapDef == null) {
			toggleMapDef = new JToggleButton();
			toggleMapDef.setText("Map Definition ");
			toggleMapDef.setSelected(true);
			toggleMapDef.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					if (toggleMapDef.isSelected()) {
						for (JFrame f : mapDefineFrames) {
							f.setVisible(true);
						}
					} else {
						for (JFrame f : mapDefineFrames) {
							f.setVisible(false);
						}
					}
				}
			});

		}
		return toggleMapDef;
	}

} // @jve:decl-index=0:visual-constraint="10,10"
